﻿namespace FastCreateProject.Helpers
{
    public class WebHelper
    {
        public static bool IsMobileRequest(string userAgent)
        {
            var ua = userAgent.ToUpper();
            if (ua.Contains("ANDROID"))
            {
                return true;
            }

            if (ua.Contains("IPHONE"))
            {
                return true;
            }

            if (ua.Contains("IPAD"))
            {
                return true;
            }

            if (IsAlipayRequest(userAgent))
            {
                return true;
            }

            if (IsWeixinRequest(userAgent))
            {
                return true;
            }

            return false;
        }

        public static bool IsWeixinRequest(string userAgent)
        {
            var ua = userAgent.ToUpper();
            if (ua.Contains("MICROMESSENGER"))
            {
                return true;
            }

            return false;
        }

        public static bool IsAlipayRequest(string userAgent)
        {
            var ua = userAgent.ToUpper();
            if (ua.Contains("ALIPAYCLIENT"))
            {
                return true;
            }

            return false;
        }
    }
}
